package com.hezuti.common.url.dispatch;

/*

**
* 根据种子的Hash值来确定使用的Url
* 
* @author 
* 
*/
public class HashStrategy {

	private String seed;

	private IpObject[] urls = null;

	public HashStrategy(String seed) {
		this.seed = seed;
	}

	public IpObject getUrl() {
		if (urls == null)
			return null;

		int index = Math.abs(seed.hashCode() % urls.length);

		return urls[index];
	}

	public void put(IpObject[] urls) {
		this.urls = urls;
	}
}
